#include "wuFader.h"

wuFader::wuFader()
{
}

wuFader::~wuFader()
{
}

void wuFader::setControl(ofImage *_skin, ofRectangle _rect)
{
	control.setup(_skin, _rect);
	value = 0.0;
	cout << "control captured";
}

void wuFader::draw(bool bCambiazo)
{
	wuBaseControl::draw();
	control.draw();

	if(!bCambiazo)
	{
		string msg;	//drawBitmapString is limited to some numebr of characters -> is this a bug in 007 or always the case?
		msg = ofToString(value);
		ofDrawBitmapString(msg, control.getPosition().x-15, control.getPosition().y-15);
	}
}

void wuFader::touch(vector <ofPoint> * _fingerList)
{
	for(int i=0; i< _fingerList->size(); i++)
	{
		if(rect.inside((*_fingerList)[i]))
		{
			value =  -((rect.y-(*_fingerList)[i].y)/rect.height);

			// move controlSkin
			ofPoint _pos;
			_pos.x = rect.x+(rect.width/2);
			_pos.y = (*_fingerList)[i].y;
			control.setPosition(_pos);
		}
	}

}

